<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改退货</title>
<script language="javascript">
    $(document).ready(function(){
        $("#saveForm").click(function () {
            var goods_sku = $("#goods_sku").val();
            var goods_name= $("#goods_name").val();
            if(!goods_sku){
                alert("商品SKU不能为空!");return false;
            }
            if(!goods_name){
                alert("该商品编号不存在!");return false;
            }
            var factory = $("#factory").val();
            if(!factory){
                alert("工厂必须选择!");return false;
            }
            var producttype = $("#producttype").val();
            if(!producttype){
                alert("商品型号必须选择!");return false;
            }
            var ordernum = $("#ordernum").val();
            if(!ordernum||ordernum==0){
                alert("数量不能为空!");return false;
            }
            var property = $("#property").val();
            var mborder = $("#mborder").val();
            var fmorder = $("#fmorder").val();
            var descr = $("#descr").val();
            var id = $("#id").val();
            if(!id){
                alert("无法更新!");return false;
            }
            //提交请求
            $.post("/stocks/editReturnGoods",{"goods_sku":goods_sku,"goods_name":goods_name,"ordernum":ordernum,"property":property,"mborder":mborder,"fmorder":fmorder,"factory":factory,"producttype":producttype,"descr":descr,"id":id},function(data){
                if(data.code == 200)
                {
                    alert(data.msg);
                    location.reload();
                }else{
                    alert(data.msg);return false;
                }
            },"json");






        });
    });
    function checkDecimal(obj) {
        var decimalReg=/^\d{0,9}\)?$/; //只能输入数字
        //var decimalReg = /^\d+(?=\.{0,1}\d+$|$)/; //可以输入数字或小数点
        if(obj.value!=""&&decimalReg.test(obj.value)){
        }else {
            if (obj.value != "") {
                //alert('非法值！请重新输入！');return ;
                obj.value = 0
            }
        }
    }
    function getSku()
    {
        var sku = $("#goods_sku").val();
        if(sku){
            //搜索该商品编号对应的价格信息
            $.post("/stocks/ajaxbutton?op=searchGoodsSku",{goods_sku: sku},function(data){
                if(data.code)
                {
                    $("#skuerr").html('');
                    $("#goods_name").val(data.msg);
                }else{
                    $("#goods_name").val("");
                    $("#skuerr").html(data.msg).css('color','red');
                }
            },"json");
        }else{
            $("#skuerr").html('没有输入任何数据!').css('color','red');
        }
    }
</script>
<body class="withvernav">
<div class="bodywrapper"> {{include file='/public/leftmenu.tpl'}}
    <div class="centercontent">
        <div class="pageheader notab">
            <h1 class="pagetitle">修改退货信息</h1>
        </div>
        <!--pageheader-->
        <div id="contentwrapper" class="contentwrapper">
            <div id="basicform" class="subcontent">
                <form class="stdform stdform2"  id="otherForm" method="post" action="/stocks/addReturnGoods" enctype="multipart/form-data" >
                    <input type="hidden" id="hidden_data" value="" />

                    <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
                        <thead>
                        <tr>
                            <th colspan="2" class="head1">修改退货</th>
                        </tr>
                        </thead>
                    </table>
                    <table cellpadding="0" cellspacing="0" border="0" class="stdtable" style="table-layout: fixed;">
                        <tbody>
                        <tr>
                            <td class="head1">
                                商品SKU：
                                <input type="text" id = "goods_sku" name="goods_sku" onBlur="getSku(this)" readonly class="width300" value="{{$goodslist.sku}}" class="width100 hasDatepicker">
                                <input type="hidden" id = "id" name="id"  value="{{$goodslist.id}}" >

                                <span style="color:red;font-size: 16px;">* 必填项</span>
                                <br/>
                                <span id="skuerr"></span>
                            </td>
                            <td class="head0">
                                中文名称：
                                <input type="text" id = "goods_name" name="goods_name" readonly class="width300" value="{{$goodslist.skuname}}" class="width100 hasDatepicker">
                            </td>
                        </tr>
                        <tr>
                            <td class="head1">
                                数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;量：
                                <input type="text" id = "ordernum" name="ordernum" class="width300" value="{{$goodslist.ordernum}}" class="width100 hasDatepicker" onblur="checkDecimal(this)">
                                <span style="color:red;font-size: 16px;">* 必填项</span>
                            </td>
                            <td class="head0">
                                属性标注：
                                <select class="selectCss2" name="property" id="property" style="width: 300px;">>
                                    <option value="">请选择</option>
                                    <option value="直接退货" {{if $goodslist.property eq "直接退货"}}selected{{/if}}> 直接退货 </option>
                                    <option value="客户退货" {{if $goodslist.property eq "客户退货"}}selected{{/if}}> 客户退货 </option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="head1">
                                <span style="color:red;">马帮订单：</span>
                                <input type="text" id = "mborder" name="mborder" class="width300" value="{{$goodslist.mborderid}}" class="width100 hasDatepicker">
                            </td>
                            <td class="head0">
                                <span style="color:red;">复漫订单：</span>
                                <input type="text" id = "fmorder" name="fmorder" class="width300" value="{{$goodslist.fmorderid}}" class="width100 hasDatepicker">
                            </td>
                        </tr>
                        <tr>
                            <td class="head1" colspan="2">
                                工&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;厂：
                                <select class="selectCss2" name="factory" id="factory" style="width: 300px;">
                                    <option value="">请选择</option>
                                    <option value="1" {{if $goodslist.factory eq 1}}selected{{/if}}> 工厂1 </option>
                                    <option value="2" {{if $goodslist.factory eq 2}}selected{{/if}}> 工厂2 </option>
                                </select>
                                <span style="color:red;font-size: 16px;">* 必选项</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="head1" colspan="2">
                                商品型号：
                                <select class="selectCss2" name="producttype" id="producttype" style="width: 300px;">
                                    <option value="">请选择</option>
                                    {{foreach from=$lists item=rs key=key}}
                                    <option value="{{$rs.id}}" {{if $goodslist.producttype eq $rs.id}}selected{{/if}}>{{$rs.measure}},{{$rs.type}},{{$rs.age}}</option>
                                    {{/foreach}}
                                </select>
                                <span style="color:red;font-size: 16px;">* 必选项</span>
                            </td>
                        </tr>
                        <tr id="beizhu">
                            <td class="head1" colspan="2">
                                描述：
                                <textarea name="descr" id="descr" cols="10" rows="8" placeholder="请输入相关描述">
                                    {{$goodslist.descr}}
                                </textarea>
                            </td>
                        </tr>
                        </tbody>
                    </table>


                    <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
                        <thead>
                        <tr>
                            <td><button type="button" class="btn btn-primary" id="saveForm">确认保存</button>
                            </td>
                        </tr>
                        </thead>
                    </table>
                </form>
                <br />
            </div>
            <!--subcontent-->

            <!--subcontent-->

        </div>
        <!--contentwrapper-->

    </div>
    <!-- centercontent -->

</div>
<!--bodywrapper-->

</body>
</html>